//
//  ViewController.m
//  DEMO5
//
//  Created by J on 16/5/12.
//  Copyright © 2016年 J. All rights reserved.
//

#import "ViewController.h"
#import "Person.h"
#import "Student.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.


    
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
   
    copyStudent();
}

void copyStudent(){
    Student * p1 = [Student new];//对象的真实类型是右边初始化的时候分配内存那一瞬间所使用的类型 而不是左边指针的类型
    p1.name = @"zhangsan";
    p1.age = @22;
    p1.number = @"001";

    Student * p2 = [p1 copy];
    Student * p3 = [p1 mutableCopy];
    
    
    NSLog(@"\n %@ \n %@ \n %@",p1,p2,p3);
    
    
}
void copyPerson(){
    Person * p1 = [Person new];
    p1.name = @"zhangsan";
    p1.age = @22;
    Person * p2 = [p1 copy];
    Person * p3 = [p1 mutableCopy];
    
    
    NSLog(@"\n %@ \n %@",p1,p2);

    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
